home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
MODULA_2
/
2394.ZIP
/
M2TOOLS1.ZIP
/
STRINGS2.DEF
< prev
next >
Wrap
Text File
|
1990-08-09
|
4KB
|
128 lines
DEFINITION MODULE Strings2;
CONST
MaxStringLength = 80;
TYPE
STRING = ARRAY [0.. MaxStringLength] OF CHAR;
(*****************************************************************************)
(* *)
(* P R O C E D U R E S *)
(* ------------------- *)
(* *)
(*****************************************************************************)
PROCEDURE Rept (Char : CHAR;
Num : CARDINAL);
(* This procedure will display character Char, Num times.
The cursor is placed at the end of the string *)
PROCEDURE FastRept (Char : CHAR;
Num : CARDINAL;
Attrib : CARDINAL);
(* This procedure will display Num Chars of attribute type Attrib.
The cursor position remains at the beginning of the string *)
PROCEDURE InitStr (VAR String : ARRAY OF CHAR;
Char : CHAR;
Length : CARDINAL);
(* This procedure will assign a string of characters to the string
String.
e.g. InitStr (Str, " ", 3) = Str := " ";
InitStr (Str, 0C, 80) = Str := "" *)
PROCEDURE IsInString (Ch : CHAR;
String : ARRAY OF CHAR) : INTEGER;
(* This procedure will determine whether Ch is in String.
Result -1 : not in string
>=0 : position in string *)
PROCEDURE MoveToRight (VAR Str : ARRAY OF CHAR;
Start : CARDINAL;
Places : CARDINAL);
(* This procedure will shift string Str Places places to the right,
starting at character position Start.
The new inserted characters are spaces.
e.g. MoveToRight ("ABCDEFG", 2, 2) -> Str = "AB CDEFG" *)
PROCEDURE MoveToLeft (VAR Str : ARRAY OF CHAR;
Start : CARDINAL;
Places : CARDINAL);
(* This procedure will shift string Str Places places to the left,
starting at character position Start.
The eol character is moved as well.
e.g. MoveToLeft ("ABCDEFG", 3, 2) -> Str = "ADEFG" *)
PROCEDURE LTrim (VAR String : ARRAY OF CHAR);
(* This procedure will remove any spaces from the beginning of the string.
e.g. " 1234" becomes "1234" *)
PROCEDURE Trim (VAR String : ARRAY OF CHAR);
(* This procedure will remove any trailing spaces from the string.
e.g. "Hello World! " becomes "Hello World!" *)
PROCEDURE EditString (VAR String : ARRAY OF CHAR;
TotStrLength : CARDINAL;
KeyList : ARRAY OF CHAR) : CARDINAL;
(* This allows a default string String to be edited with upto TotStrLength
characters. This function is not far dissimilar to the standard
Modula-2 procedure ReadString, except that the default string is
displayed and can be acted upon with the following keys:
RightArrow - Move one character to the right (unless at max length)
LeftArrow - Move one character to the left (unless at start of line)
Home - Move to beginning of line
End - Move to end of line
The function also returns a number:
0 - The string was terminated normally (ie <RETURN>)
Scan Code - Of one of the special characters entered in KeyList (eg
PgUp, PgDn, F1, etc)
27 - If <ESC> pressed.
See TestEdit.MOD for an example of this function's use. *)
PROCEDURE ws (String : ARRAY OF CHAR);
(* Quick call of WriteString *)
PROCEDURE wls (String : ARRAY OF CHAR);
(* Procedure call of WriteString with a WriteLn at the end *)
PROCEDURE WriteCentre (String : ARRAY OF CHAR);
(* This procedure will display string in the centre of a line *)
PROCEDURE WriteRight (String : ARRAY OF CHAR);
(* This procedure will display a string String justified to the right *)
END Strings2.